﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using DbUtility;
using MvcPager;

namespace Models
{
	#region 实体模型
    public partial class scoresetting:INotifyPropertyChanged
    {

		        /// <summary>
        /// 属性更改通知
        /// </summary>
        private List<string> _ChangedList = new List<string>();
        /// <summary>
        /// 属性更改通知
        /// </summary>
        [ColumnAttribute("ChangedList", true, false, true)]
        public List<string> ChangedList{get{return _ChangedList;}}
        /// <summary>
        /// 客户端通知事件
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string propName)
        {
                if (_ChangedList == null || !_ChangedList.Contains(propName))
                {
                        _ChangedList.Add(propName);

                }
                 if(PropertyChanged != null)
                {
                        PropertyChanged(this, new PropertyChangedEventArgs(propName));

                }
        }
        /// <summary>
        ///id
        /// </summary>
        private Int32 _id;
        /// <summary>
        ///id
        /// </summary>
        [ColumnAttribute("id", false, true, false)]
        public Int32 id { get { return _id;} set{_id = value;OnPropertyChanged("id");} } 


        /// <summary>
        ///createdate
        /// </summary>
        private DateTime _createdate;
        /// <summary>
        ///createdate
        /// </summary>
        [ColumnAttribute("createdate", false, false, false)]
        public DateTime createdate { get { return _createdate;} set{_createdate = value;OnPropertyChanged("createdate");} } 


        /// <summary>
        ///createuserid
        /// </summary>
        private Int32 _createuserid;
        /// <summary>
        ///createuserid
        /// </summary>
        [ColumnAttribute("createuserid", false, false, false)]
        public Int32 createuserid { get { return _createuserid;} set{_createuserid = value;OnPropertyChanged("createuserid");} } 


        /// <summary>
        ///modifydate
        /// </summary>
        private DateTime? _modifydate;
        /// <summary>
        ///modifydate
        /// </summary>
        [ColumnAttribute("modifydate", false, false, true)]
        public DateTime? modifydate { get { return _modifydate;} set{_modifydate = value;OnPropertyChanged("modifydate");} } 


        /// <summary>
        ///modifyuserid
        /// </summary>
        private Int32? _modifyuserid;
        /// <summary>
        ///modifyuserid
        /// </summary>
        [ColumnAttribute("modifyuserid", false, false, true)]
        public Int32? modifyuserid { get { return _modifyuserid;} set{_modifyuserid = value;OnPropertyChanged("modifyuserid");} } 


        /// <summary>
        ///isdeleted
        /// </summary>
        private Boolean _isdeleted;
        /// <summary>
        ///isdeleted
        /// </summary>
        [ColumnAttribute("isdeleted", false, false, false)]
        public Boolean isdeleted { get { return _isdeleted;} set{_isdeleted = value;OnPropertyChanged("isdeleted");} } 


        /// <summary>
        ///专家打分是否排除最高分和最低分
        /// </summary>
        private Boolean _isexcludeminandmax;
        /// <summary>
        ///专家打分是否排除最高分和最低分
        /// </summary>
        [ColumnAttribute("isexcludeminandmax", false, false, false)]
        public Boolean isexcludeminandmax { get { return _isexcludeminandmax;} set{_isexcludeminandmax = value;OnPropertyChanged("isexcludeminandmax");} } 


        /// <summary>
        ///专家打分占比
        /// </summary>
        private Decimal _expertpercent;
        /// <summary>
        ///专家打分占比
        /// </summary>
        [ColumnAttribute("expertpercent", false, false, false)]
        public Decimal expertpercent { get { return _expertpercent;} set{_expertpercent = value;OnPropertyChanged("expertpercent");} } 




    }
	#endregion
	#region 基本业务
    public partial class scoresettingLogic : BaseService
    {
        
        /// <summary>
        /// 构造函数
        /// </summary>
        public scoresettingLogic()
        {
            db = new DBContext();
        }
	    /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="obj">操作数据库对象</param>
        public scoresettingLogic(DBContext obj)
        {
            db = obj;
        }
        /// <summary>
        /// 添加scoresetting
        /// </summary>
        /// <param name="obj">添加对象</param>
        /// <returns>成功True失败False</returns>
        public bool Add(scoresetting obj)
        {
            try
            {
				if (obj.id > 0) throw new Exception("数据库已存在此数据");

                string result = base.Add(obj);

                return base.Save(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
		/// <summary>
        /// 添加scoresetting
        /// </summary>
        /// <param name="obj">添加对象</param>
        /// <returns>返回id</returns>
        public int Create(scoresetting obj)
        {
            try
            {
			    if (obj.id > 0) throw new Exception("数据库已存在此数据");
                string result = base.Add(obj);
                base.Save(result);
                return Convert.ToInt32(new DBContext().ExecuteScalarSql("select max(id) from [scoresetting]"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
		/// <summary>
        /// 批量添加
        /// </summary>
        public bool Add(List<scoresetting> obj)
        {
            try
            {
                List<string> result = new List<string>();

                foreach (scoresetting item in obj)
                {
                    if (item.id == 0)
                    {
                        string sql = base.Add(item);
                        result.Add(sql);
                    }
                }

                return base.Save(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 修改scoresetting
        /// </summary>
        /// <param name="obj">修改对象</param>
        /// <returns>成功True失败False</returns>
        public bool Update(scoresetting obj)
        {
            try
            {
				if (obj.id == 0) throw new Exception("数据库不存在当前数据");
                string result = base.Update(obj);
                return base.Save(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
		/// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="olts"></param>
        /// <returns></returns>
        public bool Update(List<scoresetting> olts)
        {
            try
            {
                string sql = "";
                foreach (var item in olts)
                {
                    sql += base.Update(item) + " ";
                }
                return base.Save(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
		/// <summary>
        /// 根据编号删除scoresetting，此处为逻辑删除，实为更新IsDelete字段
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns>成功True失败False</returns>
        public bool Delete(int id)
        {
            try
            {
                string result = base.Update(new scoresetting { id = id, isdeleted = true });

                return base.Save(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
		/// <summary>
        /// 删除scoresetting，此处为逻辑删除，实为更新IsDelete字段
        /// </summary>
        /// <param name="obj">删除对象</param>
        /// <returns>成功True失败False</returns>
        public bool Delete(scoresetting obj)
        {
            string sql = "";
            try
            {
                var olts = base.GetObjects<scoresetting>(obj);
                if (olts != null)
                {
                    foreach (var item in olts)
                    {
                        if (item.id > 0)
                        {
                            item.isdeleted = true;
                            sql += base.Update(item) + " ";
                        }
                    }
					return base.Save(sql);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return false;
        }
		/// <summary>
        /// 删除scoresetting集合，此处为逻辑删除，实为更新IsDelete字段
        /// </summary>
        /// <param name="objs">删除对象集合</param>
        /// <returns>成功True失败False</returns>
        public bool Delete(IList<scoresetting> objs)
        {
            try
            {
                if (objs == null || objs.Count == 0) return false;

                StringBuilder sql = new StringBuilder();

                foreach (var item in objs)
                {
                    if (item.id > 0)
                    {
                        item.isdeleted = true;

                        string result = base.Update(item) + " ";

                        sql.Append(result);
                    }
                }

                return base.Save(sql.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

		/// <summary>
        /// 根据编号删除scoresetting，物理删除
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns>成功True失败False</returns>
        public bool Remove(int id)
        {
            try
            {
                string result = base.Delete(new scoresetting { id = id });

                return base.Save(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
		/// <summary>
        /// 根据编号删除scoresetting，物理删除
        /// </summary>
        /// <param name="obj">查询条件对象</param>
        /// <returns>成功True失败False</returns>
        public bool Remove(scoresetting obj)
        {
            try
            {
			    if (obj.id < 1) throw new Exception("数据库不存在当前数据");
                string result = base.Delete(obj);
                return base.Save(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
		/// <summary>
        /// 根据编号删除scoresetting，物理删除
        /// </summary>
        /// <param name="obj">查询条件对象</param>
        /// <returns>成功True失败False</returns>
        public bool Remove(IList<scoresetting> objs)
        {
            try
            {
                string result = "";
                foreach (var obj in objs)
                {
                    if (obj.id > 0)
                    {
                        result = base.Delete(obj);
                        base.Save(result);
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 获取scoresetting集合
        /// </summary>
        /// <returns>返回scoresetting集合</returns>
        public List<scoresetting> Getscoresettings()
        {
            List<scoresetting> objs = base.GetObjects<scoresetting>(new scoresetting() { isdeleted = false });

            return objs;
        }
        /// <summary>
        /// 获取scoresetting集合
        /// </summary>
        /// <param name="obj">查询条件</param>
        /// <returns>返回scoresetting集合</returns>
        public List<scoresetting> Getscoresettings(scoresetting obj)
        {
            obj.isdeleted = false;

            List<scoresetting> objs = base.GetObjects(obj);

            return objs;
        }
		 /// <summary>
        /// 获取scoresetting集合
        /// </summary>
        /// <param name="obj">查询条件</param>
        /// <param name="where">特殊条件</param>
        /// <returns>返回scoresetting集合</returns>
        public List<scoresetting> Getscoresettings(scoresetting obj, string where)
        {
            obj.isdeleted = false;

            List<scoresetting> objs = base.GetObjects(obj, where);

            return objs;
        }
        /// <summary>
        /// 获取scoresetting集合
        /// </summary>
        /// <param name="obj">查询条件</param>
        /// <param name="where">特殊条件</param>
        ///  <param name="orderby">排序</param>
        /// <returns>返回scoresetting集合</returns>
        public List<scoresetting> Getscoresettings(scoresetting obj,string where, string order)
        {
            obj.isdeleted = false;

            List<scoresetting> objs = base.GetObjects(obj, where, order,string.Empty);

            return objs;
        }
		/// <summary>
        /// 获取scoresetting集合
        /// </summary>
        /// <param name="obj">查询条件</param>
        /// <param name="where">特殊条件</param>
        /// <param name="orderby">排序</param>
        /// <param name="orderbyType">排序类型</param>
        /// <returns>返回scoresetting集合</returns>
        public List<scoresetting> Getscoresettings(scoresetting obj, string where,string order,string by)
        {
            obj.isdeleted = false;

            List<scoresetting> objs = base.GetObjects(obj, where, order,by);

            return objs;
        }
        /// <summary>
        /// 获取scoresetting集合
        /// </summary>
        /// <param name="pageIndex">页数</param>
        /// <param name="pageCount">每页多少条</param>
        /// <returns>返回scoresetting集合</returns>
        public Page<scoresetting> Getscoresettings(int pageIndex, int pageCount)
        {
            Page<scoresetting> objs = base.GetObjects(new scoresetting() { isdeleted = false }, pageIndex, pageCount);

            return objs;
        }
        /// <summary>
        /// 获取scoresetting集合
        /// </summary>
        /// <param name="pageIndex">页数</param>
        /// <param name="pageCount">每页多少条</param>
        /// <param name="obj">查询条件</param>
        /// <returns>返回scoresetting集合</returns>
        public Page<scoresetting> Getscoresettings(scoresetting obj, int pageIndex, int pageCount)
        {
            obj.isdeleted = false;

            Page<scoresetting> objs = base.GetObjects(obj,pageIndex, pageCount);

            return objs;
        }
		/// <summary>
        /// 获取scoresetting集合
        /// </summary>
        /// <param name="pageIndex">页数</param>
        /// <param name="pageCount">每页多少条</param>
        /// <param name="obj">查询条件</param>
        /// <returns>返回scoresetting集合</returns>
        public Page<scoresetting> Getscoresettings(string sql, int pageIndex, int pageCount)
        {
            Page<scoresetting> objs = base.GetObjects<scoresetting>(sql, pageIndex, pageCount);
            return objs;
        }
        /// <summary>
        /// 获取scoresetting集合
        /// </summary>
        /// <param name="pageIndex">页数</param>
        /// <param name="pageCount">每页多少条</param>
        /// <param name="obj">查询条件</param>
        ///  <param name="where">自定义查询条件</param>
        /// <returns>返回scoresetting集合</returns>
        public Page<scoresetting> Getscoresettings(scoresetting obj, int pageIndex, int pageCount, string where)
        {
            obj.isdeleted = false;

            Page<scoresetting> objs = base.GetObjects(obj, pageIndex, pageCount, where);

            return objs;
        }
		 /// <summary>
        /// 获取scoresetting集合
        /// </summary>
        /// <param name="pageIndex">页数</param>
        /// <param name="pageCount">每页多少条</param>
        /// <param name="obj">查询条件</param>
        ///  <param name="orderby">排序</param>
        /// <returns>返回scoresetting集合</returns>
        public Page<scoresetting> Getscoresettings(scoresetting obj, int pageIndex, int pageCount, string order, string by)
        {
            obj.isdeleted = false;

            Page<scoresetting> objs = base.GetObjects(obj, pageIndex, pageCount, string.Empty, order,by);

            return objs;
        }
		/// <summary>
        /// 获取scoresetting集合
        /// </summary>
        /// <param name="pageIndex">页数</param>
        /// <param name="pageCount">每页多少条</param>
        /// <param name="obj">查询条件</param>
        ///  <param name="orderby">排序</param>
        /// <returns>返回scoresetting集合</returns>
        public Page<scoresetting> Getscoresettings(scoresetting obj, int pageIndex, int pageCount,string where, string order, string by)
        {
            obj.isdeleted = false;

            Page<scoresetting> objs = base.GetObjects(obj, pageIndex, pageCount, where, order, by);

            return objs;
        }
        /// <summary>
        /// 获取scoresetting
        /// </summary>
        /// <param name="obj">查询条件</param>
        /// <returns>返回scoresetting</returns>
        public scoresetting Getscoresetting(scoresetting obj)
        {
			obj.isdeleted = false;
			
            scoresetting entity = base.GetObject(obj);

            return entity;
        }
        /// <summary>
        /// 根据编号获取scoresetting
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns>返回scoresetting</returns>
        public scoresetting Getscoresetting(int id)
        {
            scoresetting entity = base.GetObject(new scoresetting { id = id, isdeleted = false });

            return entity;
        }

    }
	#endregion

	#region 基本数据库访问
    internal partial class scoresettingService : BaseService
    {
         /// <summary>
        /// 构造函数
        /// </summary>
        public scoresettingService()
        {
            db = new DBContext();
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="obj">操作数据库对象</param>
        public scoresettingService(DBContext obj)
        {
            db = obj;
        }
      
    }
	#endregion
}